from django.db import models
from utils.common_model import BaseModel


class ServiceProvider(BaseModel):
    '''
    服务商
    '''
    name = models.CharField(max_length=128, unique=True)
    contact_email = models.EmailField(blank=True, null=True)
    description = models.TextField(blank=True, null=True)

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'ccsp_service_provider'
        verbose_name_plural = '服务提供商'


class Service(BaseModel):
    name = models.CharField(max_length=128, unique=True)
    icon = models.FileField(upload_to='icon')
    description = models.TextField(blank=True, null=True)
    provider = models.ManyToManyField(to=ServiceProvider)
    rake = models.FloatField(verbose_name='抽成', default=0.2)
    class Meta:
        db_table = 'ccsp_service_server'
        verbose_name_plural = '服务内容'

    def __str__(self):
        return self.name
